home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 476-500 / disk_496 / memmometer / mm.doc < prev    next >
Text File  |  1992-05-06  |  21KB  |  340 lines

  1. /*
  2.  *   Information for MM Version 2.20, 19-May-1991
  3.  *
  4.  *   MemMometer - A program hacked from Tom Rokicki's WFrags more or less...
  5.  *   (in fact, a heck of a lot) in the style of Peter Da Silva's "Gauge."
  6.  *   The program opens a narrow window with the same dimensions as the disk
  7.  *   capacity gadget found in the top-level workbench window for an Amiga
  8.  *   DOS v1.3 floppy volume.  The sizing gadget is like the one in Gauge;
  9.  *   to resize the window, just click the left mouse button over the "E".
  10.  *   The "F" is the program title in this rather short manifestation of
  11.  *   an Amiga Intuition window drag bar.
  12.  *
  13.  *   My bin copy of Gauge broke when I put a Michigan Insider in my A1000.
  14.  *   I did not have source for the Gauge program, so I conjured this one.
  15.  *   To my chagrin, MM 1.0 broke when I got a 2000 (more on that shortly),
  16.  *   the Amiga 3000 blew away the previous version of this program, too,
  17.  *   of course.  But that's the way it is with hardware-oriented software
  18.  *   hacks! :-|  Changes with this version involve reconstruction of the
  19.  *   fast ram address menus to accomodate the A3000's 32-bit address space
  20.  *   for fast ram at 7000000 to 7FFFFFF hex.  Please note that Amiga DOS
  21.  *   allocates this space in heap fashion (autoconfiguring memory in
  22.  *   successively lower addresses starting from the top, while utilizing
  23.  *   it within each zone in the usual fashion from the bottom up).  The
  24.  *   following table describes how to set MM for various Amiga 3000 memory
  25.  *   configurations:
  26.  *                          Fast Ram Size    Base Address
  27.  *                              1 Meg           7f00000
  28.  *                              2 Meg           7e00000
  29.  *                              3 Meg           7d00000
  30.  *                              4 Meg           7c00000
  31.  *                              6 Meg           7a00000
  32.  *                              8 Meg           7800000
  33.  *                             10 Meg           7600000
  34.  *                             12 Meg           7400000
  35.  *                             14 Meg           7200000
  36.  *                             16 Meg           7000000
  37.  *   
  38.  *   MemMometer may be started from an icon, a CLI, or the Run command
  39.  *   from a CLI.  MM uses dynamic allocation for its display data, and
  40.  *   does its own resource tracking.  MM will surrender any resources
  41.  *   which it has successfully obtained from allocation requests if,
  42.  *   while MM is running, requested resources are denied.  This type
  43.  *   of fault (exit code 20) proceeds silently, and without prior notice.
  44.  *
  45.  *   Now for a run through MemMometer's menu mechanics.  MemMometer opens
  46.  *   with a non-interlaced-screen-height narrow window at the left side of
  47.  *   the Workbench screen.  The window width is the same as the width of the
  48.  *   capacity gauge which Workbench used to render at the left side of the
  49.  *   v1.3 top level window for a floppy volume.  As with Peter Da Silva's
  50.  *   original gauge program, the MemMometer has an E at the bottom of the
  51.  *   window, and an F at the top.
  52.  *
  53.  *   The E and the F are respectively, the window sizing gadget, and the
  54.  *   window titlebar.  While MemMometer can and does automatically arrange
  55.  *   the window to suit the memory configuration, it depends on the user to
  56.  *   select appropriate memory size and address values via the menus.  The
  57.  *   menu style is the usual Amiga Intuition menu set; selection is achieved
  58.  *   by clicking the left mouse button while the mouse pointer is anywhere
  59.  *   within the program's window boundary, and then activating the menu bar
  60.  *   by holding down the right mouse button and sliding the mouse pointer
  61.  *   along the Workbench screen title bar at the top of the Workbench screen.
  62.  *
  63.  *   At the left side of the Workbench screen title is the Project Menu.  The
  64.  *   Project Menu has three options.  The first option is "Front", which is a
  65.  *   window-to-front command for the event that the MM window was partially
  66.  *   buried by the opening of new windows after MM was invoked.   If the
  67.  *   right mouse button is released while the mouse pointer is directly over
  68.  *   the Front menu item, the MM window will oblige by popping forward to an
  69.  *   unobstructed view.  The second menu option is the "Back" item, which
  70.  *   will move the MM window back behind any other windows that have been
  71.  *   opened on the Workbench screen (with exception of a backdrop window).
  72.  *   The third Project menu option is the "Quit" option, which directs MM to
  73.  *   close its window and release the AmigaDOS resources it has allocated.
  74.  *   The normal return code is zero.
  75.  *
  76.  *   The second Intuition menu is the Setup menu.  There are two Setup menu
  77.  *   items.  The first item is the "Mode" item.  MM has two modes, and they
  78.  *   are selected by sliding the mouse pointer straight down from the screen
  79.  *   title bar over the Mode item , and then moving the pointer to the right
  80.  *   as the mode submenu is activated.  The activated submenu provides two
  81.  *   choices, "Frags" and "Warps".  Frags are rather much the same as they
  82.  *   were in Da Silva's gauge program.  "Frags" is the default menu selection
  83.  *   with which MM is first initialized.  The Frags display is described in
  84.  *   the following table:
  85.  *   
  86.  *               2-Color Workbench    4-Color Workbench    8-Color Workbench
  87.  *  Unallocated        Blue                 Black                Black
  88.  *  Allocated          White                Orange               Yellow
  89.  *  Fragmented         Blue                 Blue                 Blue 
  90.  *
  91.  *   Unallocated memory is free memory available to programs.  The programs
  92.  *   may obtain this memory from AmigaDOS through allocation requests.  The
  93.  *   Allocated memory is memory assigned to programs running under AmigaDOS.
  94.  *   Fragmented memory consists of interleaved small memhunks, some of which
  95.  *   are assigned to programs and some of which are in the free memory pool.
  96.  *   The smallest fragments are 8 bytes, and the largest memhunks may be more
  97.  *   than a megabyte.  The fragmented class is assigned when, in making the
  98.  *   MM window display, a single horizontal pixel line was found to represent
  99.  *   both allocated and unallocated memhunks.  For this reason, for a full
  100.  *   window height MemMometer, the resolution of the fragmentation is shown
  101.  *   in more detail on interlaced Amiga Workbench screens.
  102.  *
  103.  *   The second mode item selection is the "Warps" mode.  While the Frags
  104.  *   mode is usually utilized as a low-priority background indicator, the
  105.  *   Warps mode is usually utilized at a somewhat higher priority for the
  106.  *   purpose of tracking bugs and system irregularities.  In this context,
  107.  *   I define warps as a form of discretized sample-to-sample differencing
  108.  *   function for some arbitrary segment of memory.  Warps are determined by
  109.  *   dividing the selected address space evenly among the MemMometer display
  110.  *   pixels, computing an assignment checkfunction for each pixel line of the
  111.  *   display on the associated assigned memory space at some sample time, and
  112.  *   then, while retaining the previous pixel-by-pixel record, repeating the
  113.  *   same evaluation the second sample time and comparing the sequentially
  114.  *   determined checksums. A "checksum" is computed by means of a sequential
  115.  *   bit-wise eXclusive OR assignment.  This type of checksum can readily
  116.  *   detect zeroed or changed values.  In the table below, logical FALSE is
  117.  *   zero, logical TRUE is taken as 0xffffffff and VALUE is anything else.
  118.  *   Colors indicate the type of change.  Colors for the most part follow
  119.  *   the v1.3 standard CBM workbench color set; they're shown as follows:
  120.  *   
  121.  *                    Pen #   Color           Pen #   Color
  122.  *                      0     Blue              4     Green
  123.  *                      1     White             5     Red
  124.  *                      2     Black             6     Cyan
  125.  *                      3     Orange            7     Yellow
  126.  *
  127.  *   These colors are used to map the changes in memory content from sample
  128.  *   to sample as programs multitask together:
  129.  *
  130.  *   Condition        2-Color Workbench  4-Color Workbench  8-Color Workbench
  131.  *
  132.  *   VALUE ===> VALUE         Blue               Blue               Blue
  133.  *   VALUE =/=> VALUE         White              Orange             Orange
  134.  *   FALSE ===> FALSE         Blue               Black              Black
  135.  *   FALSE ---> VALUE         White              Orange             Yellow
  136.  *   VALUE ---> FALSE         White              White              Red
  137.  *   TRUE  ---> FALSE         Blue               Black              Cyan 
  138.  *   TRUE  ---> VALUE         Blue               Black              Cyan 
  139.  *   TRUE  ===> TRUE          Blue               Blue               Green
  140.  *   FALSE ---> TRUE          Blue               Blue               Green
  141.  *   VALUE ---> TRUE          Blue               Blue               Green
  142.  *
  143.  *   The second Setup menu item is a Frequency selection submenu.  While the
  144.  *   selected value does set a minimum frequency with which the memory state
  145.  *   will be examined, it's done by introducing a delay between measurements.
  146.  *   The introduced delay will be equal in seconds to the value selected in
  147.  *   the submenu.  The delay is accomplished by the AmigaDOS timer.device
  148.  *   using the VBLANK mode.  It was not thought worth the difficulty to make
  149.  *   the timing as precise as would be possible using the cia.resource, as
  150.  *   that might make the resource less useful to other programs, and as well
  151.  *   would mean extra effort adjusting for memory size-dependent scan times
  152.  *   from the various memory sizes selectable with the MM program.  Delay
  153.  *   intervals of 1, 2, 5, and 10 seconds are available.
  154.  *
  155.  *   The third Intuition menu is a Priority menu.  This menu applies only to
  156.  *   the MemMometer program and its associated CLI process.  Initially it is
  157.  *   at priority 0 with the expectation that the user will set it lower once
  158.  *   the program is running, in order to give more time to the other active
  159.  *   processes the user will be running.  A value of -50 is recommended.  In
  160.  *   the event the Priority of MM is changed via the menu, the CLI inherits
  161.  *   MemMometer's new priority and retains that priority even after MM quits.
  162.  *   Thus, with extreme priority settings, it may be better to "Run MM" to
  163.  *   keep from passing the extreme priority to subsequent processes spawned
  164.  *   from the CLI that was used to invoke MemMometer.  Also, go easy with the
  165.  *   positive priorities; remember that with AmigaDOS version 2.0 the DOS
  166.  *   input.device runs priority 20, the SCSI bus handler is 12, SCSI.device
  167.  *   is 11,  FileSystem is priority 10, and the CON: and trackdisk.device
  168.  *   are priority 5 usually.  Note that the first three MemMometer menu
  169.  *   items are used to increment or decrement a priority selected in the
  170.  *   lower part of the menu.  Selection of the "NORM" menu item removes any
  171.  *   increment or decrement previously set while at any given level.
  172.  *
  173.  *   The remaining Intuition menu selections are provided so that the range
  174.  *   and base address of the memory examined may be adjusted for the user's
  175.  *   Amiga memory configuration.  Note that the base address must always be
  176.  *   set to the correct base address for the given memory configuration in
  177.  *   order for the Frags option to work properly, but that the range may be
  178.  *   adjusted to give a better resolution for the first segments around the
  179.  *   base address, if desired.  Menus are provided for Chip memory, the old
  180.  *   Slow-Fast (C00000/Ranger) memory, and Fast memory.  While I have had no
  181.  *   difficulty as a result of selecting a range of memory that involved a
  182.  *   non-existent seqment for Chip or Fast memory in either Frags or Warps
  183.  *   mode, when I selected non-existent SFMemory on my Fat Agnus Amiga 2000
  184.  *   in Warps mode, it resulted in a total system-wide red Guru 4 (illegal
  185.  *   instruction exception).
  186.  *
  187.  *   After that, I decided to post a requester for the user to issue terse
  188.  *   warning that a crash is _possible_ with incorrectly specified menu
  189.  *   selections in warps mode.  Since it is possible, for example, to roll
  190.  *   over on 24-bit addresses via large memory size menu selections, one
  191.  *   can access forbidden zones through inappropriate settings of the Fast
  192.  *   Mem menus as well.  Thus MM also calls the requester if the Fast Mem
  193.  *   size menu is changed. The requester displays the message:
  194.  *
  195.  *                        WARNING! CRASH POSSIBLE
  196.  *                      MENU MEMORY SELECTIONS MUST
  197.  *                       REFERENCE EXISTING MEMORY
  198.  *
  199.  *                   Risk It                  Retreat
  200.  *
  201.  *   You don't have to worry about a crash if you really have an amount of
  202.  *   SF or Fast memory equal or greater than the amount you specified and
  203.  *   the base address is within what you specified (the default base address
  204.  *   for SF Mem is C00000 and 200000 for A2000 Fast Mem).  Too bad I have to
  205.  *   do this, but it is a matter the hardware regards seriously, as some
  206.  *   registers do things when they are read, never mind what they do when
  207.  *   they are written!  If you really want to be annoyed, just get Bryce
  208.  *   Nesbitt's Enforcer program.  It will yap at you through the serial port
  209.  *   every time any program (such as this one) reads the zero page...
  210.  *
  211.  *   So, here you see the two options.  The left button says - Risk It -.
  212.  *   That's a comfortable gamble if you know your Fast memory configuration.
  213.  *   Pre Fat-Agnus Amiga 2000 machines have 512K of Slow-Fast memory.  The
  214.  *   Newer 2000s have no C00000 Slow Fast memory, and the A3000 only has the
  215.  *   200000 ZorroII 16-bit Fast Memory if you added a Mem card - so beware
  216.  *   of this and try the other settings when you have nothing else going on,
  217.  *   until you gain a knowledge of what is safe.  The - Retreat - option sets
  218.  *   the SF or Fast Memory Size selected internal to the MemMometer program
  219.  *   to zero and clears the display.  (It does leave the menu items checked,
  220.  *   though, so you will have to remember to re-select suitable menu values
  221.  *   in order to get the display to show something in each existing memory
  222.  *   type.  For Chip and Fast memory this will simply entail going back into
  223.  *   the menu and again selecting whatever was previously checked.  The SF
  224.  *   memory size should be set either to appropriate values or to "NONE".)
  225.  *   
  226.  *   Note that in the display there may at any time be anywhere from one
  227.  *   to three MemMometers - for Chip (left-hand column), another for the
  228.  *   Slow Fast mem (center column) and yet another for Fast mem (right-hand
  229.  *   column).  These MemMometers can be turned on or off as desired by
  230.  *   selecting "NONE" or the various items in the Size menus.
  231.  *
  232.  *   Parts of several freely distributable  programs have been used to make
  233.  *   MemMometer.  Menus, for instance, are done in the style VT100 (Wecker,
  234.  *   et al).  As with the VT100 program, MemMometer has preset variables.
  235.  *   However, the program does not yet contain a script file reader or an
  236.  *   AREXX interface with which to automatically set the variables.  Likely
  237.  *   it is that I'll write the code for that some time this century!
  238.  *
  239.  *   MemMometer uses forbid() and permit() when it examines the mem list in
  240.  *   Frags mode.  I suppose it is possible with large amounts of memory to
  241.  *   scan, that some gross treachery can happen while the list is locked.
  242.  *   However, with my 4 meg Amiga 3000 I've not seen it.  It takes a while
  243.  *   after startup to settle out and display the large byte counts associated
  244.  *   with Fast mem, so be patient...  MemMometer is most useful for finding
  245.  *   out why large programs won't load.  It's also useful in development for
  246.  *   seeing the impact your application is having on memory fragmentation,
  247.  *   or how various programs (and viruses, for that matter) are allocating
  248.  *   memory.
  249.  *
  250.  *   The Warps mode displays any change it sees in memory from one sample
  251.  *   to the next; BUT this mode only works sensibly when JUST ONE memory size
  252.  *   selection is active (set others to "NONE").  The memory space is scanned
  253.  *   asynchronously, so it can have sample alias difficulties.  However, the
  254.  *   Warps mode does not use forbid(), permit(), enable(), disable(), or any
  255.  *   other constrictive system call.  It just does a lot of read-only memory
  256.  *   cycles and writes the result in its own dynamically allocated memory
  257.  *   space.
  258.  *
  259.  *   To run MemMometer, simply type
  260.  *
  261.  *      run MM
  262.  *
  263.  *      or  click on the icon.
  264.  *
  265.  *   Then open the menu item selections and set them for your configuration.
  266.  *   Frags mode, and 512K of CHIP @0 is the default these days, what with
  267.  *   hugh variety of configurations routinely encountered.  The modes are
  268.  *   are color coded into the "F" and "E" indicators in accordance with the
  269.  *   AmigaDOS v1.3 color table; AmigaDOS v2.0 looks pale by comparison:
  270.  *
  271.  *   Mode       Indicator       2 color WB      4 Color WB      8 Color WB
  272.  *
  273.  *   Frags          E                Blue            Blue            Blue
  274.  *   Warps          E                White           Orange          Yellow
  275.  *
  276.  *   One column:
  277.  *   Chip           F                Blue            Blue            Blue  
  278.  *   Slow-Fast      F                Blue            Black           Cyan
  279.  *   Fast           F                White           Orange          Yellow
  280.  *
  281.  *   Two columns:
  282.  *   Chip +SF       F                Blue            Blue            Blue
  283.  *   Chip +Fast     F                Blue            Black           Cyan
  284.  *   SF + Fast      F                White           Orange          Yellow
  285.  *
  286.  *   Three columns:
  287.  *   C + SF + Fast  F                Blue            Blue            Blue
  288.  *   None           F                White           Orange          Orange
  289.  *
  290.  *   The source code included with this distribution was compiled with the
  291.  *   Manx Aztec C compiler, version 3.6a in 16-bit integer mode.  Numerous
  292.  *   type casts in the code, as well as other non-alignments with the Lattice
  293.  *   environment would make compilation under versions of Lattice difficult.
  294.  *   Sorry.  Compilation instructions are of course in the makefile included
  295.  *   in the distribution.
  296.  *
  297.  *   About my part of C code - it wasn't done for speed, as I am sure you can
  298.  *   tell.  If I wanted speed I would have used assembly language.  It also
  299.  *   likely isn't elegant code, by a long shot (unless it's the part I got
  300.  *   from Rokicki's WFrags).  But assembly language is time-consuming to
  301.  *   write, so that won't happen any time soon.  Maybe the next thing will be
  302.  *   the AREXX port - so that other programs can specify a low address and a
  303.  *   byte count range for one of the MemMometers to display (say, within the
  304.  *   specified menu selection span).  Gross comments about the code or bug
  305.  *   reports may be e-mailed to me at the site domain specified below.
  306.  *
  307.  *   About everyone else's C code in MM - Let's see, VT100 (Wecker et al) has
  308.  *   been freely distributable since the early days of the Amiga.  When VT100
  309.  *   was first posted, Wecker did not prepend a copyright to the code.  He
  310.  *   later discovered that his employer (DEC) routinely required employees to
  311.  *   sign a contract statement which granted to DEC all rights with respect
  312.  *   to codes written by DEC employees, whether the codes were written on the
  313.  *   company's time/facilities or otherwise.  I do not know how the matter
  314.  *   was resolved, but VT100 still seems to be on the freely distributable
  315.  *   software list.  The menus in MM, while styled with the same code forms
  316.  *   as were used with VT100 v2.3, are of course different in content in any
  317.  *   case.  The WFrags program was, I believe, a version by Tom Rokicki (the
  318.  *   Amiga Tex guy) might be evolved from the Frags program originally put
  319.  *   to the net by Mike Meyer.  WFrags was submitted to the net without a
  320.  *   prepended copyright notice, evidently intended  as freely distributable
  321.  *   software.
  322.  *
  323.  *   The spirit of these contributions is that they are not to be used for
  324.  *   commercial purposes, and the original authors certainly appreciate
  325.  *   being cited for their work.  So I just did that.  The timer codes are
  326.  *   exerpted from a network article by Andy Finkel of CBM, submitted as a
  327.  *   demonstration of the ease of implementing the Amiga timer.device in C.
  328.  *
  329.  *   So, for my part, I add no further restrictions to the codes in MM.
  330.  *   In that spirit, I hereby submit the following Standard Disclaimer:
  331.  *
  332.  *   The authors accept no responsibility for anything either beneficial or
  333.  *   detrimental that may happen as a result of using the codes in MM.  The
  334.  *   codes are intended for non-commercial use only.
  335.  *   
  336.  *
  337.  *   Howard Hull  hull@ncar.edu
  338.  *
  339.  */
  340.